<?php
if( !isset($_SESSION['user_id']) ){
	session_unset();
	setcookie("user_id", '' , 1);
	if('ajax' == $dataType){
		if( $isJSON == 1 )
			exit('{"status":"error","detail":"noLogin","msg":"还没有登录,请登录"}');
		else
			exit('<span class="error" style="padding-left:20px;">还没有登录,请<a href="'.WEB_ROOT_PATH.'?option=login" target="_blank">登录</a></span>');
	}
	else
		header('Location:'. urlRewrite('option=login'));
}
	
$user_id = $_SESSION['user_id'];
$username = $_SESSION['userName'];	
$password = $_SESSION['passWord'];
$randompass = $_SESSION['randomPass'];

if( 0 != $user_id ){
	$sql = 'SELECT * FROM `'.DB_PRE.'user` WHERE `id` = '. $user_id .' and `userName` = "'. $username .'" and `passWord` = "'. $password .'" '; 
	// and `randomPass` = "'. $randompass .'" ';
	$user = $dbs -> select($sql);
	$user = $user[0];
	
	$myInfo = $user ;
	
	if( 0 == count($user) ){
		 session_unset();
		 header('Location:'. urlRewrite('option=login'));
		 exit();
	}
	initUserLogin($user);
	$user = new users();
	
	
	$userStatus = $user -> getUser('');
	$userStatus = $userStatus['status'];
	if( $userStatus <= 0 ){
		header('Location:'. urlRewrite('option=userLock'));
		exit();
	}
}

?>